package com.marquisx.tzdice.model;

import com.marquisx.tzdice.database.DiceRecordDBAdapter;

import android.content.Context;

public class DiceRecordManager
{
	private static DiceRecordManager instance;
	private Context context;
	private DiceRecordDBAdapter dbAdapter;
	
	private DiceRecordManager (Context context)
	{
		this.context = context;
		dbAdapter = new DiceRecordDBAdapter(context);
	}
	
	public static DiceRecordManager getInstance(Context context)
	{
		if( instance != null)
		{
			instance.setContext(context);
			return instance;
		}
		else
		{
			return new DiceRecordManager(context);
		}
	}
	
	public void setContext(Context context)
	{
		this.context = context;
	}
	
	public void closeDB()
	{
		dbAdapter.close();
	}
	
	public void removeAllActions()
	{
		dbAdapter.open().deleteAll();
		dbAdapter.close();
	}
}
